package org.sissgr.com{
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.Responder;
	
	import mx.controls.Alert;
	
	import org.sissgr.com.connAMFPHP;
	
	import spark.components.BorderContainer;
	
	
	public class Mesa extends BorderContainer
	{
		private var gateway:connAMFPHP;
		
		override protected function createChildren():void{
			super.createChildren();
			
			this.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); 
			this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
		}
		
		
		private function mouseUpHandler(e:Event):void
		{
			this.stopDrag()
			actualizaPosicionMesa(int(this.id), int(this.x), int(this.y));
		}
		
		private function mouseDownHandler(e:Event):void
		{
			this.startDrag();
		}
		
		private function actualizaPosicionMesa(idMesa:int, x:int, y:int):void
		{
			gateway = new connAMFPHP("http://localhost/sisgr/amfphp/gateway.php");
			gateway.call("viewMesas.actualizaPosicionMesa", new Responder( function (result:Array):void{},onFault),idMesa,x,y);
			
		}
		
		public function onFault( fault : String ) : void
		{
			Alert.show(fault);
		}
		
		
	}

}